import Block from "../base/block";
import {globalCtx, px, winH, winW} from "../libs/utils";
import Img from "../base/img";
import {PageStatus} from "../page_status";
import DataBus from "../databus";
import {isLikeNone} from "../libs/petlib";
import JsLogic, {LogicDebugMode} from "./jslogic";
import Text from "../base/text";


/**
 * 游戏基础的页面
 */
export default class Scene extends Block {

    constructor() {
        super();
        this.isInit = false;
    }

    /// 逻辑处理
    update() {
    }
    initView(ctx){

    }

    // 页面返回按钮
    backPage(){
        this.emptyChild();
        this.isInit = false;
    }

    /// 渲染
    render(ctx) {

        if(this.isInit === false){
            this.isInit = true;
            this.initView(ctx)

        }
        this.drawToCanvas(ctx)
    }

    addDebugView(){
        if(LogicDebugMode){
            var testImg = new Img("js/sub/images/icon_test.png",60, 20, 40, 40);
            testImg.bgColor = 'white'
            testImg.bindClickEvent(()=>{
                if(isLikeNone(this.albumView) === false&& this.albumView.visible === true){
                    return;
                }
                let dataBus = new DataBus()
                if(dataBus.gameStatus === PageStatus.LogicTest){
                    return;
                }
                dataBus.gameStatus = PageStatus.LogicTest;
                this.emptyChild()
                this.isInit = false;
            });
            this.addChild(testImg,'testImg')
        }
    }

    /// 事件处理
    onTouchEvent(type, x, y, callback) {
    }


}
